<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <script type="text/javascript" src="../../js/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
  </head>
  
  <body>
	<div class="x-body">
		<form class="layui-form" lay-filter="Textform">
			
			<div class="layui-form-item" style="width:300px;">
				<label class="layui-form-label"><span class="x-red">*</span>区域名称</label>
				<div class="layui-input-block" id = "view">
					<select id="cleanAreaId" name="cleanAreaId">
	
	  				</select>
				</div>
			</div>
			<div class="layui-form-item" style="width:300px;">
				<label class="layui-form-label"><span class="x-red">*</span>人员姓名</label>
				<div class="layui-input-block" id = "view">
					<select id="cleanManId" name="cleanManId">
			
	  				</select>
				</div>
			</div>
			<div class="layui-form-item">
              <label for="name" class="layui-form-label">
                  <span class="x-red">*</span>日期
              </label>
              <div class="layui-input-inline">
                 <input type="text" class="layui-input" id="misTime" name="misTime" placeholder="日期" lay-verify="required"
                        autocomplete="off">
              </div>
          	</div>
          	<div class="layui-form-item" style="width:300px;">
				<label class="layui-form-label"><span class="x-red">*</span>是否完成</label>
				<div class="layui-input-block" id = "view">
					<select id="isFinish" name="isFinish">
						<option value="0" >未完成</option>
						<option value="1" >已完成</option>
	  				</select>
				</div>
			</div>
          	 <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red"></span>备注
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="other" name="other" 
                        autocomplete="off" class="layui-input">
                    </div>
             </div>
			<div class="layui-form-item">
				<label for="L_repass" class="layui-form-label"> </label>
				<button class="layui-btn" lay-filter="add" lay-submit="">
					增加</button>
			</div>
		</form>
	</div>
	<script>
	layui.use(['form','layer','laydate'], function(){
        var form = layui.form
        ,layer = layui.layer;
        var laydate = layui.laydate;
    	  //常规用法
    	  laydate.render({
    	    elem: '#misTime'
    	  });
        $(function(){
        	
        	$.ajax({
        		type: "post",
              	url: "../../admin/clean/findallarea",
              	async: true,
              	success:function(result){
              		
              		$.each(result.arealist,function(index,value){
              			//下列2种方法其中一种都可以
              		    //$("#selectvillage").append(new Option(value.villageName,value.villageId));
              		    $("#cleanAreaId").append("<option value="+value.cleanAreaId+">"+value.cleanAreaName+"</option>");
              		    form.render();
              		});
              	},
              	error:function(){
              		layer.msg("保洁区域的信息没有正确地加载到选择菜单中!",{icon:6,time:1500});
              	}
              	
        	});
        	$.ajax({
        		type: "post",
              	url: "../../admin/clean/findallman",
              	async: true,
              	success:function(result){
              		
              		$.each(result.manlist,function(index,value){
              			//下列2种方法其中一种都可以
              		    //$("#selectvillage").append(new Option(value.villageName,value.villageId));
              		    $("#cleanManId").append("<option value="+value.cleanManId+">"+value.cleanManName+"</option>");
              		    form.render();
              		});
              	},
              	error:function(){
              		layer.msg("保洁人员的信息没有正确地加载到选择菜单中!",{icon:6,time:1500});
              	}
              	
        	});
        });
        
        

        //监听提交
        form.on('submit(add)', function(data){
        	
        	
          $.ajax({
          	type: "post",
          	url: "../../admin/clean/addmis",
          	async: true,
          	data: data.field,
          	success: function(result) {
          		console.log("ok");
          		if(result.msg == 'success') {
            			layer.msg("添加成功",{icon:6,time:1500},function(){
            				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            				parent.layer.close(index); //再执行关闭   
            				parent.location.reload();
                		});
          		} else {
          			layer.msg("添加失败",{icon:5,time:1500},function(){
              			
            			});
          		} 
          	},   	
          	error: function() {
                  layer.alert("数据异常", {icon: 2,time:1500});
              }
          });
          return false;
        });
      });
	</script>

  </body>

</html>